package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelDifferences;
import com.ktgj.hotel.service.IHotelDifferencesService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 酒店差异Controller
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@RestController
@RequestMapping("/differences")
public class HotelDifferencesController extends BaseController
{
    @Autowired
    private IHotelDifferencesService hotelDifferencesService;

    /**
     * 查询酒店差异列表
     */
    @PreAuthorize(hasPermi = "hotel:differences:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelDifferences hotelDifferences)
    {
        startPage();
        List<HotelDifferences> list = hotelDifferencesService.selectHotelDifferencesList(hotelDifferences);
        return getDataTable(list);
    }

    /**
     * 导出酒店差异列表
     */
    @PreAuthorize(hasPermi = "hotel:differences:export")
    @Log(title = "酒店差异", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelDifferences hotelDifferences) throws IOException
    {
        List<HotelDifferences> list = hotelDifferencesService.selectHotelDifferencesList(hotelDifferences);
        ExcelUtil<HotelDifferences> util = new ExcelUtil<HotelDifferences>(HotelDifferences.class);
        util.exportExcel(response, list, "酒店差异数据");
    }

    /**
     * 获取酒店差异详细信息
     */
    @PreAuthorize(hasPermi = "hotel:differences:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hotelDifferencesService.selectHotelDifferencesById(id));
    }

    /**
     * 新增酒店差异
     */
    @PreAuthorize(hasPermi = "hotel:differences:add")
    @Log(title = "酒店差异", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelDifferences hotelDifferences)
    {
        return toAjax(hotelDifferencesService.insertHotelDifferences(hotelDifferences));
    }

    /**
     * 修改酒店差异
     */
    @PreAuthorize(hasPermi = "hotel:differences:edit")
    @Log(title = "酒店差异", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelDifferences hotelDifferences)
    {
        return toAjax(hotelDifferencesService.updateHotelDifferences(hotelDifferences));
    }

    /**
     * 删除酒店差异
     */
    @PreAuthorize(hasPermi = "hotel:differences:remove")
    @Log(title = "酒店差异", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hotelDifferencesService.deleteHotelDifferencesByIds(ids));
    }
}
